class OuterClass{
    public int a1=1;
    private int a2=2;
    public static int a3=3;
    static class InnerClass{
        public int a4=4;
        private int a5=5;
        public static int a6=6;
        public void fun(){
            //静态内部类的方法中不可以直接访问外部类的非静态成员变量
           /*System.out.println(a1);
            System.out.println(a2);*/
            //需要通过外部类对象的引用来访问
            OuterClass outerClass=new OuterClass();
            System.out.println(outerClass.a1);
            System.out.println(outerClass.a2);
            //下面的访问形式也不可以
          //  System.out.println(OuterClass.this.a1);
            System.out.println(a3);
            System.out.println(a4);
            System.out.println(a5);
            System.out.println(a6);
        }
    }

    public void test(){
        InnerClass innerClass1=new InnerClass();
        innerClass1.fun();
    }

}
public class Test {
    public static void main(String[] args) {
        //静态内部类创建
        OuterClass.InnerClass innerClass=new OuterClass.InnerClass();
        innerClass.fun();
        System.out.println("------------------");
        OuterClass outerClass=new OuterClass();
        outerClass.test();
    }
}
